//
//package com.migu.rbac.config;
//
//import com.migu.rbac.constant.MybatisConstant;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.mapper.MapperScannerConfigurer;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.AutoConfigureAfter;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.core.io.support.ResourcePatternResolver;
//
//import javax.sql.DataSource;
//
///**
// * Mybatis & Mapper & PageHelper 配置
// *
// * @author summer
// */
//
//@Configuration
//public class MybatisConfigurer {
//    @Autowired
//    private DataSource dataSource;
//
//    @Bean
//    public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
//        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
//        bean.setDataSource(dataSource);
//        bean.setTypeAliasesPackage(MybatisConstant.MODEL_PACKAGE);
//        //添加XML目录
//        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//        bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
//        return bean.getObject();
//    }
//
//    @Configuration
//    @AutoConfigureAfter(MybatisConfigurer.class)
//    public static class MyBatisMapperScannerConfigurer {
//        @Bean
//        public MapperScannerConfigurer mapperScannerConfigurer() {
//            MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
//            mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactoryBean");
//            mapperScannerConfigurer.setBasePackage(MybatisConstant.MAPPER_PACKAGE);
//            return mapperScannerConfigurer;
//        }
//    }
//}
//
//
